package com.hxkj.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QueueConfig {
    /**
     * article
     * @return
     */
    @Bean
    public Queue articleQueue(){
        return new Queue(MQConstant.ARTICLE_QUEUE);
    }

    @Bean
    public TopicExchange articleExchange(){
        return new TopicExchange(MQConstant.CMS_EXCHANGE);
    }

    @Bean
    public Binding bindingArticleExchange(Queue articleQueue, TopicExchange articleExchange){
        return BindingBuilder.bind(articleQueue).to(articleExchange).with(MQConstant.ARTICLE_ROUTING_KEY);
    }

    /**
     * channel
     * @return
     */
    @Bean
    public Queue channelQueue(){
        return new Queue(MQConstant.CHANNEL_QUEUE);
    }

    @Bean
    public TopicExchange channelExchange(){
        return new TopicExchange(MQConstant.CMS_EXCHANGE);
    }

    @Bean
    public Binding bindingChannelExchange(Queue channelQueue, TopicExchange channelExchange){
        return BindingBuilder.bind(channelQueue).to(channelExchange).with(MQConstant.CHANNEL_ROUTING_KEY);
    }

    /**
     * leaflet
     * @return
     */
    @Bean
    public Queue leafletQueue(){
        return new Queue(MQConstant.LEAFLET_QUEUE);
    }

    @Bean
    public TopicExchange leafletExchange(){
        return new TopicExchange(MQConstant.CMS_EXCHANGE);
    }

    @Bean
    public Binding bindingleafletExchange(Queue leafletQueue, TopicExchange leafletExchange){
        return BindingBuilder.bind(leafletQueue).to(leafletExchange).with(MQConstant.LEAFLET_ROUTING_KEY);
    }

    /**
     * column
     * @return
     */
    @Bean
    public Queue columnQueue(){
        return new Queue(MQConstant.COLUMN_QUEUE);
    }

    @Bean
    public TopicExchange columnExchange(){
        return new TopicExchange(MQConstant.CMS_EXCHANGE);
    }

    @Bean
    public Binding bindingColumnExchange(Queue columnQueue, TopicExchange columnExchange){
        return BindingBuilder.bind(columnQueue).to(columnExchange).with(MQConstant.COLUMN_ROUTING_KEY);
    }

    @Bean
    public Queue tagsQueue(){
        return new Queue(MQConstant.TAGS_QUEUE);
    }

    @Bean
    public TopicExchange tagsExchange(){
        return new TopicExchange(MQConstant.CMS_EXCHANGE);
    }

    @Bean
    public Binding bindingTagsExchange(Queue tagsQueue, TopicExchange tagsExchange){
        return BindingBuilder.bind(tagsQueue).to(tagsExchange).with(MQConstant.TAGS_ROUTING_KEY);
    }

    @Bean
    public Queue tagInfoQueue(){
        return new Queue(MQConstant.TAG_INFO_QUEUE);
    }

    @Bean
    public TopicExchange tagInfoExchange(){
        return new TopicExchange(MQConstant.CMS_EXCHANGE);
    }

    @Bean
    public Binding bindingTagInfoExchange(Queue tagInfoQueue, TopicExchange tagInfoExchange){
        return BindingBuilder.bind(tagInfoQueue).to(tagInfoExchange).with(MQConstant.TAG_INFO_ROUTING_KEY);
    }
}
